package com.mall.product.service;

import com.mall.common.core.text.Convert;
import com.mall.common.utils.DateUtils;
import com.mall.product.domain.biz.ProProductRecommendedBiz;
import com.mall.product.domain.entity.ProProductRecommended;
import com.mall.product.domain.req.ProProductRecommendedRequest;
import com.mall.product.mapper.ProProductRecommendedMapper;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品推荐Service业务层处理
 *
 * @author zhonglin
 * @date 2020-05-24
 */
@Service
public class ProProductRecommendedService {

  @Autowired
  private ProProductRecommendedMapper proProductRecommendedMapper;

  /**
   * 查询商品推荐
   *
   * @param productRecommendedId 商品推荐ID
   *
   * @return 商品推荐
   */
  public ProProductRecommendedBiz selectProProductRecommendedById(Long productRecommendedId) {

    return proProductRecommendedMapper.selectProProductRecommendedById(productRecommendedId);
  }

  /**
   * 查询商品推荐列表
   *
   * @param proProductRecommended 商品推荐
   *
   * @return 商品推荐
   */
  public List<ProProductRecommendedBiz> selectProProductRecommendedList(ProProductRecommendedRequest proProductRecommended) {

    return proProductRecommendedMapper.selectProProductRecommendedList(proProductRecommended);
  }

  /**
   * 新增商品推荐
   *
   * @param proProductRecommended 商品推荐
   *
   * @return 结果
   */
  public int insertProProductRecommended(ProProductRecommended proProductRecommended) {

    proProductRecommended.setCreateTime(DateUtils.getNowDate());
    return proProductRecommendedMapper.insertProProductRecommended(proProductRecommended);
  }

  /**
   * 修改商品推荐
   *
   * @param proProductRecommended 商品推荐
   *
   * @return 结果
   */
  public int updateProProductRecommended(ProProductRecommended proProductRecommended) {

    proProductRecommended.setUpdateTime(DateUtils.getNowDate());
    return proProductRecommendedMapper.updateProProductRecommended(proProductRecommended);
  }

  /**
   * 删除商品推荐对象
   *
   * @param ids 需要删除的数据ID
   *
   * @return 结果
   */
  public int deleteProProductRecommendedByIds(String ids) {

    return proProductRecommendedMapper.deleteProProductRecommendedByIds(Convert.toStrArray(ids));
  }

  /**
   * 删除商品推荐信息
   *
   * @param productRecommendedId 商品推荐ID
   *
   * @return 结果
   */
  public int deleteProProductRecommendedById(Long productRecommendedId) {

    return proProductRecommendedMapper.deleteProProductRecommendedById(productRecommendedId);
  }

}
